﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Happy.Archetype;
using Happy.Domain;

namespace Happy.Security.Domain.Users
{
    [Factory]
    public sealed class UserFactory : DomainService<User, Guid, IUserRepository>
    {
        public User Create(string username, string plantextPassword)
        {
            this.Repository.AssertUserNameNotExists(username);
            var password = PasswordService.Encrypte(plantextPassword);

            return new User(Guid.NewGuid(), username, password);
        }
    }
}
